home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / libpam0g.postinst < prev    next >
Encoding:
Text File  |  2011-10-17  |  5.0 KB  |  200 lines

  1. #!/bin/sh
  2.  
  3. # postinst based heavily on the postinst of libssl0.9.8, courtesy of 
  4. # Christoph Martin.
  5.  
  6. . /usr/share/debconf/confmodule
  7.  
  8. set -e
  9.  
  10. # element() is a helper function for file-rc:
  11. element() {
  12.     local element list IFS
  13.  
  14.     element="$1"
  15.  
  16.     [ "$2" = "in" ] && shift
  17.     list="$2"
  18.     [ "$list" = "-" ] && return 1
  19.     [ "$list" = "*" ] && return 0
  20.  
  21.     IFS=","
  22.     set -- $list
  23.     case $element in
  24.     "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
  25.         return 0
  26.     esac
  27.     return 1
  28. }
  29.  
  30. # filerc (runlevel, service) returns /etc/init.d/service, if service is
  31. # running in $runlevel:
  32. filerc() {
  33.     local runlevel basename
  34.     runlevel=$1
  35.     basename=$2
  36.     while read LINE
  37.     do
  38.     case $LINE in
  39.         \#*|"") continue
  40.     esac
  41.  
  42.     set -- $LINE
  43.     SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
  44.     [ "$CMD" = "/etc/init.d/$basename" ] || continue
  45.  
  46.     if element "$runlevel" in "$START" || element "S" in "$START"
  47.     then
  48.         echo "/etc/init.d/$basename"
  49.         return 0
  50.     fi
  51.     done < /etc/runlevel.conf
  52.     echo ""
  53. }
  54.  
  55. installed_services() {
  56.     check="$@"
  57.  
  58.     # Only get the ones that are installed, and configured
  59.     check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  60.  
  61.     # some init scripts don't match the package names
  62.     check=$(echo $check | \
  63.     sed -e's/\bapache2-common\b/apache2/g' \
  64.         -e's/\bat\b/atd/g' \
  65.         -e's/\bdovecot-common\b/dovecot/g' \
  66.         -e's/\bdante-server\b/danted/g' \
  67.         -e's/\bexim4-base\b/exim4/g' \
  68.         -e's/\bheartbeat-2\b/heartbeat/g' \
  69.         -e's/\bhylafax-server\b/hylafax/g' \
  70.         -e's/\bpartimage-server\b/partimaged/g' \
  71.         -e's/\bsasl2-bin\b/saslauthd/g' \
  72.     )
  73.  
  74.     for service in $check; do
  75.     idl="/etc/init.d/${service}"
  76.     if [ -n "$idl" ] && [ -x $idl ]; then
  77.         services="$service $services"
  78.     else
  79.         echo "WARNING: init script for $service not found." >&2
  80.     fi
  81.     done
  82.     echo "$services"
  83. }
  84.  
  85. if [ "$1" = "configure" ]
  86. then
  87.     if [ ! -z "$2" ]; then
  88.     if dpkg --compare-versions "$2" lt 1.1.1-2; then
  89.         db_version 2.0
  90.  
  91.         echo -n "Checking for services that may need to be restarted..."
  92.  
  93.         check="apache2-common at bayonne cherokee courier-authdaemon"
  94.         check="$check cron cups"
  95.         check="$check dante-server diald dovecot-common exim exim4-base"
  96.         check="$check fcron fireflier-server freeradius gdm heartbeat"
  97.         check="$check heartbeat-2 hylafax-server iiimf-server inn2"
  98.         check="$check kannel linesrv linesrv-mysql lsh-server"
  99.         check="$check muddleftpd netatalk nuauth partimage-server"
  100.         check="$check perdition pgpool popa3d"
  101.         check="$check postgresql-8.2 postgresql-8.3 proftpd pure-ftpd"
  102.         check="$check pure-ftpd-ldap pure-ftpd-mysql"
  103.         check="$check pure-ftpd-postgresql racoon samba sasl2-bin"
  104.         check="$check sfs-server solid-pop3d squid squid3 tac-plus"
  105.         check="$check vsftpd wu-ftpd wzdftpd xrdp yardradius yaws"
  106.  
  107.         if ! who | awk '{print $2}'|grep -q ':[0-9]'; then
  108.         check="$check kdm wdm xdm"
  109.         fi
  110.  
  111.         echo "Checking init scripts..."
  112.         services=$(installed_services "$check")
  113.         if [ -n "$services" ]; then
  114.         db_reset libpam0g/restart-services
  115.         db_set libpam0g/restart-services "$services"
  116.         db_input critical libpam0g/restart-services || true
  117.         db_go || true
  118.         db_get libpam0g/restart-services
  119.  
  120.         if [ "x$RET" != "x" ]
  121.         then
  122.             services=$RET
  123.         else
  124.             services=""
  125.         fi
  126.         echo
  127.         if [ "$services" != "" ]; then
  128.             echo "Restarting services possibly affected by the upgrade:"
  129.             failed=""
  130.             rl=$(runlevel | sed 's/.*\ //')
  131.             for service in $services; do
  132.             idl="invoke-rc.d ${service}"
  133.  
  134.             case "$service" in
  135.                 gdm)
  136.                 echo -n "  $service: reloading..."
  137.                 if $idl reload > /dev/null 2>&1; then
  138.                     echo "done."
  139.                 else
  140.                     echo "FAILED! ($?)"
  141.                     failed="$service $failed"
  142.                 fi
  143.                 continue
  144.                 ;;
  145.             esac
  146.             echo -n "  $service: stopping..."
  147.             $idl stop > /dev/null 2>&1 || true
  148.             sleep 1
  149.             echo -n "starting..."
  150.             if $idl start > /dev/null 2>&1; then
  151.                 echo "done."
  152.             else
  153.                 echo "FAILED! ($?)"
  154.                 failed="$service $failed"
  155.             fi
  156.             done
  157.             echo
  158.             if [ -n "$failed" ]; then
  159.             db_subst libpam0g/restart-failed services "$failed"
  160.             db_input critical libpam0g/restart-failed || true
  161.             db_go || true
  162.             else
  163.             echo "Services restarted successfully."
  164.             fi
  165.             echo
  166.         fi
  167.         else
  168.         echo "Nothing to restart."
  169.         fi
  170.  
  171.         if who | awk '{print $2}' | grep -q ':[0-9]'; then
  172.         dms=""
  173.         for service in kdm wdm xdm; do
  174.             case "$services" in
  175.             *$service*)    ;;
  176.             *)    dms="$dms $service"
  177.             esac
  178.         done
  179.         services=$(installed_services "$dms")
  180.         if [ -n "$services" ]; then
  181.             db_input critical libpam0g/xdm-needs-restart || true
  182.             db_go || true
  183.         fi
  184.         fi
  185.  
  186.         # Shut down the frontend, to make sure none of the
  187.         # restarted services keep a connection open to it
  188.         db_stop
  189.     fi # end upgrading and $2 lt 1.1.1-2
  190.     fi # Upgrading
  191. fi
  192.  
  193. # Automatically added by dh_makeshlibs
  194. if [ "$1" = "configure" ]; then
  195.     ldconfig
  196. fi
  197. # End automatically added section
  198.  
  199.  
  200.